package ch4;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.FileInputStream;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.Properties;

@WebServlet(name = "TestServlet04",value = "/test04")
public class TestServlet04 extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
ServletContext servletContext=this.getServletContext ();
String path =servletContext.getRealPath ("/aaa/db.properties");
        System.out.println (path);
        FileInputStream in  =new FileInputStream (path);
        Properties properties =new Properties ();
        properties.load (in);
        System.out.println (properties.getProperty ("name"));
        System.out.println (properties.getProperty ("password"));
    }
}
